#ifndef _KEY_H_
#define _KEY_H_

#include "Global.h"
#include "SC_GPIO.h"
#include "Config.h"
//---- ����IO�ڶ��� ----//
#if 0
#define P_L1    DEF_PIN(C,0)
#define M_L1    DEF_PIN_DIR(C, 0)
#define WPU_L1  DEF_PIN_WPU(C, 0)


#define P_L2    DEF_PIN(C,1)
#define M_L2    DEF_PIN_DIR(C, 1)
#define WPU_L2  DEF_PIN_WPU(C, 1)


#define P_L3    DEF_PIN(A,0)
#define M_L3    DEF_PIN_DIR(A, 0)
#define WPU_L3  DEF_PIN_WPU(A, 0)


#define P_L4    DEF_PIN(A,1)
#define M_L4    DEF_PIN_DIR(A, 1)
#define WPU_L4  DEF_PIN_WPU(A, 1)

#define P_L5    DEF_PIN(A,2)
#define M_L5    DEF_PIN_DIR(A, 2)
#define WPU_L5  DEF_PIN_WPU(A, 2)

#else
#define P_L1    DEF_PIN(A,2)
#define M_L1    DEF_PIN_DIR(A, 2)
#define WPU_L1  DEF_PIN_WPU(A, 2)


#define P_L2    DEF_PIN(A,1)
#define M_L2    DEF_PIN_DIR(A, 1)
#define WPU_L2  DEF_PIN_WPU(A, 1)


#define P_L3    DEF_PIN(A,0)
#define M_L3    DEF_PIN_DIR(A, 0)
#define WPU_L3  DEF_PIN_WPU(A, 0)


#define P_L4    DEF_PIN(C,1)
#define M_L4    DEF_PIN_DIR(C, 1)
#define WPU_L4  DEF_PIN_WPU(C, 1)

#define P_L5    DEF_PIN(C,0)
#define M_L5    DEF_PIN_DIR(C, 0)
#define WPU_L5  DEF_PIN_WPU(C, 0)
#endif

#define P_R1    DEF_PIN(B,6)
#define M_R1    DEF_PIN_DIR(B, 6)
#define WPU_R1  DEF_PIN_WPU(B, 6)

#define P_R2    DEF_PIN(B,7)
#define M_R2    DEF_PIN_DIR(B, 7)
#define WPU_R2  DEF_PIN_WPU(B, 7)

#define P_R3    DEF_PIN(A,7)
#define M_R3    DEF_PIN_DIR(A, 7)
#define WPU_R3  DEF_PIN_WPU(A, 7)

#define P_R4    DEF_PIN(A,6)
#define M_R4    DEF_PIN_DIR(A, 6)
#define WPU_R4  DEF_PIN_WPU(A, 6)

#define P_R5    DEF_PIN(A,5)
#define M_R5    DEF_PIN_DIR(A, 5)
#define WPU_R5  DEF_PIN_WPU(A, 5)

#define SET_IN(pin)      do{P_##pin = 1;  M_##pin = 1; WPU_##pin = 1;} while(0)
#define SET_OUT(pin,hl)  do{P_##pin = hl; M_##pin = 0; WPU_##pin = 0;} while(0)
#define GET_PIN(pin)    P_##pin


enum
{
    KEY_NONE = 0,
    KEY1 ,
    KEY2 ,
    KEY3 ,
    KEY4 ,
    KEY5 ,
    KEY6 ,
    KEY7 ,
    KEY8 ,
    KEY9 ,
    KEY10 ,
    KEY11 ,
    KEY12 ,
    KEY13 ,
    KEY14 ,
    KEY15 ,
    KEY16 ,
    KEY17 ,
    KEY18 ,
    KEY19 ,
    KEY20 ,
    KEY21 ,
    KEY22 ,
    KEY23 ,
    KEY24 ,
    KEY25 ,
    KEY_COMBO1,         //  
    KEY_COMBO2,         // 
    KEY_COMBO3,         //
};


#define KEY_TINGZHI     KEY1
#define KEY_CHONGSHUI   KEY5
#define KEY_ZUOWEN      KEY6
#define KEY_YEDENG      KEY9


#define C_TM_DLY_KEY_SCAN   20      //---- 
#define	TM_DBC_KEY		    10      //----
#define C_MAX_KEY_PRESS     2       //---- 
#define C_MAX_KEY_NUM       (25+12) //---- 
#define INVAILD_KEY         0xFF    //----

// extern void(*KeyShortFunc[18])(void);
// extern void(*KeyLongFunc[18])(void);

extern uint8 RKeyCode;


void initKEY(uint8 type);
void Key_PowerSaveSet(void);
void Key_Main(void);
void MultiKey_Proc(void);

#endif

